
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Django 2.0 release notes &#8212; Django 2.2.12.dev20200304094918 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Django 1.11.29 release notes" href="1.11.29.html" />
    <link rel="prev" title="Django 2.0.1 release notes" href="2.0.1.html" />



 
<script type="text/javascript" src="../templatebuiltins.js"></script>
<script type="text/javascript">
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "../ref/templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);</script>

  </head><body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../index.html">Django 2.2.12.dev20200304094918 documentation</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../index.html">Home</a>  |
        <a title="Table of contents" href="../contents.html">Table of contents</a>  |
        <a title="Global index" href="../genindex.html">Index</a>  |
        <a title="Module index" href="../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    &laquo; <a href="2.0.1.html" title="Django 2.0.1 release notes">previous</a>
     |
    <a href="index.html" title="Release notes" accesskey="U">up</a>
   |
    <a href="1.11.29.html" title="Django 1.11.29 release notes">next</a> &raquo;</div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="releases-2.0">
            
  <div class="section" id="s-django-2-0-release-notes">
<span id="django-2-0-release-notes"></span><h1>Django 2.0 release notes<a class="headerlink" href="#django-2-0-release-notes" title="Permalink to this headline">¶</a></h1>
<p><em>December 2, 2017</em></p>
<p>Welcome to Django 2.0!</p>
<p>These release notes cover the <a class="reference internal" href="#whats-new-2-0"><span class="std std-ref">new features</span></a>, as well as
some <a class="reference internal" href="#backwards-incompatible-2-0"><span class="std std-ref">backwards incompatible changes</span></a> you’ll
want to be aware of when upgrading from Django 1.11 or earlier. We’ve
<a class="reference internal" href="#removed-features-2-0"><span class="std std-ref">dropped some features</span></a> that have reached the end of
their deprecation cycle, and we’ve <a class="reference internal" href="#deprecated-features-2-0"><span class="std std-ref">begun the deprecation process for some
features</span></a>.</p>
<p>This release starts Django’s use of a <a class="reference internal" href="../internals/release-process.html#internal-release-cadence"><span class="std std-ref">loose form of semantic versioning</span></a>, but there aren’t any major backwards incompatible
changes that might be expected of a 2.0 release. Upgrading should be a similar
amount of effort as past feature releases.</p>
<p>See the <a class="reference internal" href="../howto/upgrade-version.html"><span class="doc">Upgrading Django to a newer version</span></a> guide if you’re updating an existing
project.</p>
<div class="section" id="s-python-compatibility">
<span id="python-compatibility"></span><h2>Python compatibility<a class="headerlink" href="#python-compatibility" title="Permalink to this headline">¶</a></h2>
<p>Django 2.0 supports Python 3.4, 3.5, 3.6, and 3.7. We <strong>highly recommend</strong> and
only officially support the latest release of each series.</p>
<p>The Django 1.11.x series is the last to support Python 2.7.</p>
<p>Django 2.0 will be the last release series to support Python 3.4. If you plan
a deployment of Python 3.4 beyond the end-of-life for Django 2.0 (April 2019),
stick with Django 1.11 LTS (supported until April 2020) instead. Note, however,
that the end-of-life for Python 3.4 is March 2019.</p>
</div>
<div class="section" id="s-third-party-library-support-for-older-version-of-django">
<span id="third-party-library-support-for-older-version-of-django"></span><h2>Third-party library support for older version of Django<a class="headerlink" href="#third-party-library-support-for-older-version-of-django" title="Permalink to this headline">¶</a></h2>
<p>Following the release of Django 2.0, we suggest that third-party app authors
drop support for all versions of Django prior to 1.11. At that time, you should
be able to run your package’s tests using <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-Wd</span></code> so that deprecation
warnings do appear. After making the deprecation warning fixes, your app should
be compatible with Django 2.0.</p>
</div>
<div class="section" id="s-what-s-new-in-django-2-0">
<span id="s-whats-new-2-0"></span><span id="what-s-new-in-django-2-0"></span><span id="whats-new-2-0"></span><h2>What’s new in Django 2.0<a class="headerlink" href="#what-s-new-in-django-2-0" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-simplified-url-routing-syntax">
<span id="simplified-url-routing-syntax"></span><h3>Simplified URL routing syntax<a class="headerlink" href="#simplified-url-routing-syntax" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../ref/urls.html#django.urls.path" title="django.urls.path"><code class="xref py py-func docutils literal notranslate"><span class="pre">django.urls.path()</span></code></a> function allows a simpler, more readable URL
routing syntax. For example, this example from previous Django releases:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">url</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;^articles/(?P&lt;year&gt;[0-9]</span><span class="si">{4}</span><span class="s1">)/$&#39;</span><span class="p">,</span> <span class="n">views</span><span class="o">.</span><span class="n">year_archive</span><span class="p">),</span>
</pre></div>
</div>
<p>could be written as:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">path</span><span class="p">(</span><span class="s1">&#39;articles/&lt;int:year&gt;/&#39;</span><span class="p">,</span> <span class="n">views</span><span class="o">.</span><span class="n">year_archive</span><span class="p">),</span>
</pre></div>
</div>
<p>The new syntax supports type coercion of URL parameters. In the example, the
view will receive the <code class="docutils literal notranslate"><span class="pre">year</span></code> keyword argument as an integer rather than as
a string. Also, the URLs that will match are slightly less constrained in the
rewritten example. For example, the year 10000 will now match since the year
integers aren’t constrained to be exactly four digits long as they are in the
regular expression.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">django.conf.urls.url()</span></code> function from previous versions is now available
as <a class="reference internal" href="../ref/urls.html#django.urls.re_path" title="django.urls.re_path"><code class="xref py py-func docutils literal notranslate"><span class="pre">django.urls.re_path()</span></code></a>. The old location remains for backwards
compatibility, without an imminent deprecation. The old
<code class="docutils literal notranslate"><span class="pre">django.conf.urls.include()</span></code> function is now importable from <code class="docutils literal notranslate"><span class="pre">django.urls</span></code>
so you can use <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">django.urls</span> <span class="pre">import</span> <span class="pre">include,</span> <span class="pre">path,</span> <span class="pre">re_path</span></code> in your
URLconfs.</p>
<p>The <a class="reference internal" href="../topics/http/urls.html"><span class="doc">URL dispatcher</span></a> document is rewritten to feature the new syntax
and provide more details.</p>
</div>
<div class="section" id="s-mobile-friendly-contrib-admin">
<span id="mobile-friendly-contrib-admin"></span><h3>Mobile-friendly <code class="docutils literal notranslate"><span class="pre">contrib.admin</span></code><a class="headerlink" href="#mobile-friendly-contrib-admin" title="Permalink to this headline">¶</a></h3>
<p>The admin is now responsive and supports all major mobile devices. Older
browsers may experience varying levels of graceful degradation.</p>
</div>
<div class="section" id="s-window-expressions">
<span id="window-expressions"></span><h3>Window expressions<a class="headerlink" href="#window-expressions" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../ref/models/expressions.html#django.db.models.expressions.Window" title="django.db.models.expressions.Window"><code class="xref py py-class docutils literal notranslate"><span class="pre">Window</span></code></a> expression allows
adding an <code class="docutils literal notranslate"><span class="pre">OVER</span></code> clause to querysets. You can use <a class="reference internal" href="../ref/models/database-functions.html#window-functions"><span class="std std-ref">window functions</span></a> and <a class="reference internal" href="../ref/models/querysets.html#aggregation-functions"><span class="std std-ref">aggregate functions</span></a> in
the expression.</p>
</div>
<div class="section" id="s-minor-features">
<span id="minor-features"></span><h3>Minor features<a class="headerlink" href="#minor-features" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-django-contrib-admin">
<span id="django-contrib-admin"></span><h4><a class="reference internal" href="../ref/contrib/admin/index.html#module-django.contrib.admin" title="django.contrib.admin: Django's admin site."><code class="xref py py-mod docutils literal notranslate"><span class="pre">django.contrib.admin</span></code></a><a class="headerlink" href="#django-contrib-admin" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>The new <a class="reference internal" href="../ref/contrib/admin/index.html#django.contrib.admin.ModelAdmin.autocomplete_fields" title="django.contrib.admin.ModelAdmin.autocomplete_fields"><code class="xref py py-attr docutils literal notranslate"><span class="pre">ModelAdmin.autocomplete_fields</span></code></a> attribute and
<a class="reference internal" href="../ref/contrib/admin/index.html#django.contrib.admin.ModelAdmin.get_autocomplete_fields" title="django.contrib.admin.ModelAdmin.get_autocomplete_fields"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ModelAdmin.get_autocomplete_fields()</span></code></a> method allow using a
<a class="reference external" href="https://select2.org">Select2</a> search widget for <code class="docutils literal notranslate"><span class="pre">ForeignKey</span></code> and
<code class="docutils literal notranslate"><span class="pre">ManyToManyField</span></code>.</li>
</ul>
</div>
<div class="section" id="s-django-contrib-auth">
<span id="django-contrib-auth"></span><h4><a class="reference internal" href="../topics/auth/index.html#module-django.contrib.auth" title="django.contrib.auth: Django's authentication framework."><code class="xref py py-mod docutils literal notranslate"><span class="pre">django.contrib.auth</span></code></a><a class="headerlink" href="#django-contrib-auth" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>The default iteration count for the PBKDF2 password hasher is increased from
36,000 to 100,000.</li>
</ul>
</div>
<div class="section" id="s-django-contrib-gis">
<span id="django-contrib-gis"></span><h4><a class="reference internal" href="../ref/contrib/gis/index.html#module-django.contrib.gis" title="django.contrib.gis: Geographic Information System (GIS) extensions for Django"><code class="xref py py-mod docutils literal notranslate"><span class="pre">django.contrib.gis</span></code></a><a class="headerlink" href="#django-contrib-gis" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Added MySQL support for the
<a class="reference internal" href="../ref/contrib/gis/functions.html#django.contrib.gis.db.models.functions.AsGeoJSON" title="django.contrib.gis.db.models.functions.AsGeoJSON"><code class="xref py py-class docutils literal notranslate"><span class="pre">AsGeoJSON</span></code></a> function,
<a class="reference internal" href="../ref/contrib/gis/functions.html#django.contrib.gis.db.models.functions.GeoHash" title="django.contrib.gis.db.models.functions.GeoHash"><code class="xref py py-class docutils literal notranslate"><span class="pre">GeoHash</span></code></a> function,
<a class="reference internal" href="../ref/contrib/gis/functions.html#django.contrib.gis.db.models.functions.IsValid" title="django.contrib.gis.db.models.functions.IsValid"><code class="xref py py-class docutils literal notranslate"><span class="pre">IsValid</span></code></a> function,
<a class="reference internal" href="../ref/contrib/gis/geoquerysets.html#std:fieldlookup-isvalid"><code class="xref std std-lookup docutils literal notranslate"><span class="pre">isvalid</span></code></a> lookup, and <a class="reference internal" href="../ref/contrib/gis/geoquerysets.html#distance-lookups"><span class="std std-ref">distance lookups</span></a>.</li>
<li>Added the <a class="reference internal" href="../ref/contrib/gis/functions.html#django.contrib.gis.db.models.functions.Azimuth" title="django.contrib.gis.db.models.functions.Azimuth"><code class="xref py py-class docutils literal notranslate"><span class="pre">Azimuth</span></code></a> and
<a class="reference internal" href="../ref/contrib/gis/functions.html#django.contrib.gis.db.models.functions.LineLocatePoint" title="django.contrib.gis.db.models.functions.LineLocatePoint"><code class="xref py py-class docutils literal notranslate"><span class="pre">LineLocatePoint</span></code></a> functions,
supported on PostGIS and SpatiaLite.</li>
<li>Any <a class="reference internal" href="../ref/contrib/gis/geos.html#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> imported from GeoJSON now
has its SRID set.</li>
<li>Added the <a class="reference internal" href="../ref/contrib/gis/forms-api.html#django.contrib.gis.forms.widgets.OSMWidget.default_zoom" title="django.contrib.gis.forms.widgets.OSMWidget.default_zoom"><code class="xref py py-attr docutils literal notranslate"><span class="pre">OSMWidget.default_zoom</span></code></a> attribute to customize the map’s
default zoom level.</li>
<li>Made metadata readable and editable on rasters through the
<a class="reference internal" href="../ref/contrib/gis/gdal.html#django.contrib.gis.gdal.GDALRaster.metadata" title="django.contrib.gis.gdal.GDALRaster.metadata"><code class="xref py py-attr docutils literal notranslate"><span class="pre">metadata</span></code></a>,
<a class="reference internal" href="../ref/contrib/gis/gdal.html#django.contrib.gis.gdal.GDALRaster.info" title="django.contrib.gis.gdal.GDALRaster.info"><code class="xref py py-attr docutils literal notranslate"><span class="pre">info</span></code></a>, and
<a class="reference internal" href="../ref/contrib/gis/gdal.html#django.contrib.gis.gdal.GDALBand.metadata" title="django.contrib.gis.gdal.GDALBand.metadata"><code class="xref py py-attr docutils literal notranslate"><span class="pre">metadata</span></code></a> attributes.</li>
<li>Allowed passing driver-specific creation options to
<a class="reference internal" href="../ref/contrib/gis/gdal.html#django.contrib.gis.gdal.GDALRaster" title="django.contrib.gis.gdal.GDALRaster"><code class="xref py py-class docutils literal notranslate"><span class="pre">GDALRaster</span></code></a> objects using <code class="docutils literal notranslate"><span class="pre">papsz_options</span></code>.</li>
<li>Allowed creating <a class="reference internal" href="../ref/contrib/gis/gdal.html#django.contrib.gis.gdal.GDALRaster" title="django.contrib.gis.gdal.GDALRaster"><code class="xref py py-class docutils literal notranslate"><span class="pre">GDALRaster</span></code></a> objects in
GDAL’s internal virtual filesystem. Rasters can now be <a class="reference internal" href="../ref/contrib/gis/gdal.html#gdal-raster-vsimem"><span class="std std-ref">created from and
converted to binary data</span></a> in-memory.</li>
<li>The new <a class="reference internal" href="../ref/contrib/gis/gdal.html#django.contrib.gis.gdal.GDALBand.color_interp" title="django.contrib.gis.gdal.GDALBand.color_interp"><code class="xref py py-meth docutils literal notranslate"><span class="pre">GDALBand.color_interp()</span></code></a> method returns the color
interpretation for the band.</li>
</ul>
</div>
<div class="section" id="s-django-contrib-postgres">
<span id="django-contrib-postgres"></span><h4><a class="reference internal" href="../ref/contrib/postgres/index.html#module-django.contrib.postgres" title="django.contrib.postgres: PostgreSQL-specific fields and features"><code class="xref py py-mod docutils literal notranslate"><span class="pre">django.contrib.postgres</span></code></a><a class="headerlink" href="#django-contrib-postgres" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>The new <code class="docutils literal notranslate"><span class="pre">distinct</span></code> argument for
<a class="reference internal" href="../ref/contrib/postgres/aggregates.html#django.contrib.postgres.aggregates.ArrayAgg" title="django.contrib.postgres.aggregates.ArrayAgg"><code class="xref py py-class docutils literal notranslate"><span class="pre">ArrayAgg</span></code></a> determines if
concatenated values will be distinct.</li>
<li>The new <a class="reference internal" href="../ref/contrib/postgres/functions.html#django.contrib.postgres.functions.RandomUUID" title="django.contrib.postgres.functions.RandomUUID"><code class="xref py py-class docutils literal notranslate"><span class="pre">RandomUUID</span></code></a> database
function returns a version 4 UUID. It requires use of PostgreSQL’s
<code class="docutils literal notranslate"><span class="pre">pgcrypto</span></code> extension which can be activated using the new
<a class="reference internal" href="../ref/contrib/postgres/operations.html#django.contrib.postgres.operations.CryptoExtension" title="django.contrib.postgres.operations.CryptoExtension"><code class="xref py py-class docutils literal notranslate"><span class="pre">CryptoExtension</span></code></a> migration
operation.</li>
<li><a class="reference internal" href="../ref/contrib/postgres/indexes.html#django.contrib.postgres.indexes.GinIndex" title="django.contrib.postgres.indexes.GinIndex"><code class="xref py py-class docutils literal notranslate"><span class="pre">django.contrib.postgres.indexes.GinIndex</span></code></a> now supports the
<code class="docutils literal notranslate"><span class="pre">fastupdate</span></code> and <code class="docutils literal notranslate"><span class="pre">gin_pending_list_limit</span></code> parameters.</li>
<li>The new <a class="reference internal" href="../ref/contrib/postgres/indexes.html#django.contrib.postgres.indexes.GistIndex" title="django.contrib.postgres.indexes.GistIndex"><code class="xref py py-class docutils literal notranslate"><span class="pre">GistIndex</span></code></a> class allows
creating <code class="docutils literal notranslate"><span class="pre">GiST</span></code> indexes in the database. The new
<a class="reference internal" href="../ref/contrib/postgres/operations.html#django.contrib.postgres.operations.BtreeGistExtension" title="django.contrib.postgres.operations.BtreeGistExtension"><code class="xref py py-class docutils literal notranslate"><span class="pre">BtreeGistExtension</span></code></a> migration
operation installs the <code class="docutils literal notranslate"><span class="pre">btree_gist</span></code> extension to add support for operator
classes that aren’t built-in.</li>
<li><a class="reference internal" href="../ref/django-admin.html#django-admin-inspectdb"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">inspectdb</span></code></a> can now introspect <code class="docutils literal notranslate"><span class="pre">JSONField</span></code> and various
<code class="docutils literal notranslate"><span class="pre">RangeField</span></code>s (<code class="docutils literal notranslate"><span class="pre">django.contrib.postgres</span></code> must be in <code class="docutils literal notranslate"><span class="pre">INSTALLED_APPS</span></code>).</li>
</ul>
</div>
<div class="section" id="s-django-contrib-sitemaps">
<span id="django-contrib-sitemaps"></span><h4><a class="reference internal" href="../ref/contrib/sitemaps.html#module-django.contrib.sitemaps" title="django.contrib.sitemaps: A framework for generating Google sitemap XML files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">django.contrib.sitemaps</span></code></a><a class="headerlink" href="#django-contrib-sitemaps" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Added the <code class="docutils literal notranslate"><span class="pre">protocol</span></code> keyword argument to the
<a class="reference internal" href="../ref/contrib/sitemaps.html#django.contrib.sitemaps.GenericSitemap" title="django.contrib.sitemaps.GenericSitemap"><code class="xref py py-class docutils literal notranslate"><span class="pre">GenericSitemap</span></code></a> constructor.</li>
</ul>
</div>
<div class="section" id="s-cache">
<span id="cache"></span><h4>Cache<a class="headerlink" href="#cache" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">cache.set_many()</span></code> now returns a list of keys that failed to be inserted.
For the built-in backends, failed inserts can only happen on memcached.</li>
</ul>
</div>
<div class="section" id="s-file-storage">
<span id="file-storage"></span><h4>File Storage<a class="headerlink" href="#file-storage" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference internal" href="../ref/files/file.html#django.core.files.File.open" title="django.core.files.File.open"><code class="xref py py-meth docutils literal notranslate"><span class="pre">File.open()</span></code></a> can be used as a context
manager, e.g. <code class="docutils literal notranslate"><span class="pre">with</span> <span class="pre">file.open()</span> <span class="pre">as</span> <span class="pre">f:</span></code>.</li>
</ul>
</div>
<div class="section" id="s-forms">
<span id="forms"></span><h4>Forms<a class="headerlink" href="#forms" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>The new <code class="docutils literal notranslate"><span class="pre">date_attrs</span></code> and <code class="docutils literal notranslate"><span class="pre">time_attrs</span></code> arguments for
<a class="reference internal" href="../ref/forms/widgets.html#django.forms.SplitDateTimeWidget" title="django.forms.SplitDateTimeWidget"><code class="xref py py-class docutils literal notranslate"><span class="pre">SplitDateTimeWidget</span></code></a> and
<a class="reference internal" href="../ref/forms/widgets.html#django.forms.SplitHiddenDateTimeWidget" title="django.forms.SplitHiddenDateTimeWidget"><code class="xref py py-class docutils literal notranslate"><span class="pre">SplitHiddenDateTimeWidget</span></code></a> allow specifying different
HTML attributes for the <code class="docutils literal notranslate"><span class="pre">DateInput</span></code> and <code class="docutils literal notranslate"><span class="pre">TimeInput</span></code> (or hidden)
subwidgets.</li>
<li>The new <a class="reference internal" href="../ref/forms/api.html#django.forms.Form.errors.get_json_data" title="django.forms.Form.errors.get_json_data"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Form.errors.get_json_data()</span></code></a> method returns form errors as
a dictionary suitable for including in a JSON response.</li>
</ul>
</div>
<div class="section" id="s-generic-views">
<span id="generic-views"></span><h4>Generic Views<a class="headerlink" href="#generic-views" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>The new <a class="reference internal" href="../ref/class-based-views/mixins-simple.html#django.views.generic.base.ContextMixin.extra_context" title="django.views.generic.base.ContextMixin.extra_context"><code class="xref py py-attr docutils literal notranslate"><span class="pre">ContextMixin.extra_context</span></code></a> attribute allows adding context
in <code class="docutils literal notranslate"><span class="pre">View.as_view()</span></code>.</li>
</ul>
</div>
<div class="section" id="s-management-commands">
<span id="management-commands"></span><h4>Management Commands<a class="headerlink" href="#management-commands" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference internal" href="../ref/django-admin.html#django-admin-inspectdb"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">inspectdb</span></code></a> now translates MySQL’s unsigned integer columns to
<code class="docutils literal notranslate"><span class="pre">PositiveIntegerField</span></code> or <code class="docutils literal notranslate"><span class="pre">PositiveSmallIntegerField</span></code>.</li>
<li>The new <a class="reference internal" href="../ref/django-admin.html#cmdoption-makemessages-add-location"><code class="xref std std-option docutils literal notranslate"><span class="pre">makemessages</span> <span class="pre">--add-location</span></code></a> option controls the comment
format in PO files.</li>
<li><a class="reference internal" href="../ref/django-admin.html#django-admin-loaddata"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">loaddata</span></code></a> can now <a class="reference internal" href="../ref/django-admin.html#loading-fixtures-stdin"><span class="std std-ref">read from stdin</span></a>.</li>
<li>The new <a class="reference internal" href="../ref/django-admin.html#cmdoption-diffsettings-output"><code class="xref std std-option docutils literal notranslate"><span class="pre">diffsettings</span> <span class="pre">--output</span></code></a> option allows formatting the output
in a unified diff format.</li>
<li>On Oracle, <a class="reference internal" href="../ref/django-admin.html#django-admin-inspectdb"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">inspectdb</span></code></a> can now introspect <code class="docutils literal notranslate"><span class="pre">AutoField</span></code> if the
column is created as an identity column.</li>
<li>On MySQL, <a class="reference internal" href="../ref/django-admin.html#django-admin-dbshell"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">dbshell</span></code></a> now supports client-side TLS certificates.</li>
</ul>
</div>
<div class="section" id="s-migrations">
<span id="migrations"></span><h4>Migrations<a class="headerlink" href="#migrations" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>The new <a class="reference internal" href="../ref/django-admin.html#cmdoption-squashmigrations-squashed-name"><code class="xref std std-option docutils literal notranslate"><span class="pre">squashmigrations</span> <span class="pre">--squashed-name</span></code></a> option allows naming the
squashed migration.</li>
</ul>
</div>
<div class="section" id="s-models">
<span id="models"></span><h4>Models<a class="headerlink" href="#models" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>The new <a class="reference internal" href="../ref/models/database-functions.html#django.db.models.functions.StrIndex" title="django.db.models.functions.StrIndex"><code class="xref py py-class docutils literal notranslate"><span class="pre">StrIndex</span></code></a> database function
finds the starting index of a string inside another string.</li>
<li>On Oracle, <code class="docutils literal notranslate"><span class="pre">AutoField</span></code> and <code class="docutils literal notranslate"><span class="pre">BigAutoField</span></code> are now created as <a class="reference external" href="https://docs.oracle.com/en/database/oracle/oracle-database/18/drdaa/intro-to-tools-and-products-supporting-migraiton.html#GUID-14E4817B-F3BC-4D99-B471-A0ACDC303CC9">identity
columns</a>.</li>
<li>The new <code class="docutils literal notranslate"><span class="pre">chunk_size</span></code> parameter of <a class="reference internal" href="../ref/models/querysets.html#django.db.models.query.QuerySet.iterator" title="django.db.models.query.QuerySet.iterator"><code class="xref py py-meth docutils literal notranslate"><span class="pre">QuerySet.iterator()</span></code></a> controls the
number of rows fetched by the Python database client when streaming results
from the database. For databases that don’t support server-side cursors, it
controls the number of results Django fetches from the database adapter.</li>
<li><a class="reference internal" href="../ref/models/querysets.html#django.db.models.query.QuerySet.earliest" title="django.db.models.query.QuerySet.earliest"><code class="xref py py-meth docutils literal notranslate"><span class="pre">QuerySet.earliest()</span></code></a>, <a class="reference internal" href="../ref/models/querysets.html#django.db.models.query.QuerySet.latest" title="django.db.models.query.QuerySet.latest"><code class="xref py py-meth docutils literal notranslate"><span class="pre">QuerySet.latest()</span></code></a>, and
<a class="reference internal" href="../ref/models/options.html#django.db.models.Options.get_latest_by" title="django.db.models.Options.get_latest_by"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Meta.get_latest_by</span></code></a> now
allow ordering by several fields.</li>
<li>Added the <a class="reference internal" href="../ref/models/database-functions.html#django.db.models.functions.ExtractQuarter" title="django.db.models.functions.ExtractQuarter"><code class="xref py py-class docutils literal notranslate"><span class="pre">ExtractQuarter</span></code></a> function to
extract the quarter from <a class="reference internal" href="../ref/models/fields.html#django.db.models.DateField" title="django.db.models.DateField"><code class="xref py py-class docutils literal notranslate"><span class="pre">DateField</span></code></a> and
<a class="reference internal" href="../ref/models/fields.html#django.db.models.DateTimeField" title="django.db.models.DateTimeField"><code class="xref py py-class docutils literal notranslate"><span class="pre">DateTimeField</span></code></a>, and exposed it through the
<a class="reference internal" href="../ref/models/querysets.html#std:fieldlookup-quarter"><code class="xref std std-lookup docutils literal notranslate"><span class="pre">quarter</span></code></a> lookup.</li>
<li>Added the <a class="reference internal" href="../ref/models/database-functions.html#django.db.models.functions.TruncQuarter" title="django.db.models.functions.TruncQuarter"><code class="xref py py-class docutils literal notranslate"><span class="pre">TruncQuarter</span></code></a> function to
truncate <a class="reference internal" href="../ref/models/fields.html#django.db.models.DateField" title="django.db.models.DateField"><code class="xref py py-class docutils literal notranslate"><span class="pre">DateField</span></code></a> and
<a class="reference internal" href="../ref/models/fields.html#django.db.models.DateTimeField" title="django.db.models.DateTimeField"><code class="xref py py-class docutils literal notranslate"><span class="pre">DateTimeField</span></code></a> to the first day of a quarter.</li>
<li>Added the <a class="reference internal" href="../ref/models/indexes.html#django.db.models.Index.db_tablespace" title="django.db.models.Index.db_tablespace"><code class="xref py py-attr docutils literal notranslate"><span class="pre">db_tablespace</span></code></a> parameter to
class-based indexes.</li>
<li>If the database supports a native duration field (Oracle and PostgreSQL),
<a class="reference internal" href="../ref/models/database-functions.html#django.db.models.functions.Extract" title="django.db.models.functions.Extract"><code class="xref py py-class docutils literal notranslate"><span class="pre">Extract</span></code></a> now works with
<a class="reference internal" href="../ref/models/fields.html#django.db.models.DurationField" title="django.db.models.DurationField"><code class="xref py py-class docutils literal notranslate"><span class="pre">DurationField</span></code></a>.</li>
<li>Added the <code class="docutils literal notranslate"><span class="pre">of</span></code> argument to <a class="reference internal" href="../ref/models/querysets.html#django.db.models.query.QuerySet.select_for_update" title="django.db.models.query.QuerySet.select_for_update"><code class="xref py py-meth docutils literal notranslate"><span class="pre">QuerySet.select_for_update()</span></code></a>, supported
on PostgreSQL and Oracle, to lock only rows from specific tables rather than
all selected tables. It may be helpful particularly when
<a class="reference internal" href="../ref/models/querysets.html#django.db.models.query.QuerySet.select_for_update" title="django.db.models.query.QuerySet.select_for_update"><code class="xref py py-meth docutils literal notranslate"><span class="pre">select_for_update()</span></code></a> is used in conjunction with
<a class="reference internal" href="../ref/models/querysets.html#django.db.models.query.QuerySet.select_related" title="django.db.models.query.QuerySet.select_related"><code class="xref py py-meth docutils literal notranslate"><span class="pre">select_related()</span></code></a>.</li>
<li>The new <code class="docutils literal notranslate"><span class="pre">field_name</span></code> parameter of <a class="reference internal" href="../ref/models/querysets.html#django.db.models.query.QuerySet.in_bulk" title="django.db.models.query.QuerySet.in_bulk"><code class="xref py py-meth docutils literal notranslate"><span class="pre">QuerySet.in_bulk()</span></code></a> allows fetching
results based on any unique model field.</li>
<li><a class="reference internal" href="../topics/db/sql.html#django.db.models.CursorWrapper.callproc" title="django.db.models.CursorWrapper.callproc"><code class="xref py py-meth docutils literal notranslate"><span class="pre">CursorWrapper.callproc()</span></code></a> now takes an optional dictionary of keyword
parameters, if the backend supports this feature. Of Django’s built-in
backends, only Oracle supports it.</li>
<li>The new <a class="reference internal" href="../topics/db/instrumentation.html#django.db.backends.base.DatabaseWrapper.execute_wrapper" title="django.db.backends.base.DatabaseWrapper.execute_wrapper"><code class="xref py py-meth docutils literal notranslate"><span class="pre">connection.execute_wrapper()</span></code></a> method allows
<a class="reference internal" href="../topics/db/instrumentation.html"><span class="doc">installing wrappers around execution of database queries</span></a>.</li>
<li>The new <code class="docutils literal notranslate"><span class="pre">filter</span></code> argument for built-in aggregates allows <a class="reference internal" href="../ref/models/conditional-expressions.html#conditional-aggregation"><span class="std std-ref">adding
different conditionals</span></a> to multiple aggregations
over the same fields or relations.</li>
<li>Added support for expressions in <a class="reference internal" href="../ref/models/options.html#django.db.models.Options.ordering" title="django.db.models.Options.ordering"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Meta.ordering</span></code></a>.</li>
<li>The new <code class="docutils literal notranslate"><span class="pre">named</span></code> parameter of <a class="reference internal" href="../ref/models/querysets.html#django.db.models.query.QuerySet.values_list" title="django.db.models.query.QuerySet.values_list"><code class="xref py py-meth docutils literal notranslate"><span class="pre">QuerySet.values_list()</span></code></a> allows fetching
results as named tuples.</li>
<li>The new <a class="reference internal" href="../ref/models/querysets.html#django.db.models.FilteredRelation" title="django.db.models.FilteredRelation"><code class="xref py py-class docutils literal notranslate"><span class="pre">FilteredRelation</span></code></a> class allows adding an <code class="docutils literal notranslate"><span class="pre">ON</span></code> clause to
querysets.</li>
</ul>
</div>
<div class="section" id="s-pagination">
<span id="pagination"></span><h4>Pagination<a class="headerlink" href="#pagination" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Added <a class="reference internal" href="../topics/pagination.html#django.core.paginator.Paginator.get_page" title="django.core.paginator.Paginator.get_page"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Paginator.get_page()</span></code></a>
to provide the documented pattern of handling invalid page numbers.</li>
</ul>
</div>
<div class="section" id="s-requests-and-responses">
<span id="requests-and-responses"></span><h4>Requests and Responses<a class="headerlink" href="#requests-and-responses" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>The <a class="reference internal" href="../ref/django-admin.html#django-admin-runserver"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">runserver</span></code></a> Web server supports HTTP 1.1.</li>
</ul>
</div>
<div class="section" id="s-templates">
<span id="templates"></span><h4>Templates<a class="headerlink" href="#templates" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>To increase the usefulness of <a class="reference internal" href="../ref/templates/api.html#django.template.Engine.get_default" title="django.template.Engine.get_default"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Engine.get_default()</span></code></a> in third-party
apps, it now returns the first engine if multiple <code class="docutils literal notranslate"><span class="pre">DjangoTemplates</span></code> engines
are configured in <code class="docutils literal notranslate"><span class="pre">TEMPLATES</span></code> rather than raising <code class="docutils literal notranslate"><span class="pre">ImproperlyConfigured</span></code>.</li>
<li>Custom template tags may now accept keyword-only arguments.</li>
</ul>
</div>
<div class="section" id="s-tests">
<span id="tests"></span><h4>Tests<a class="headerlink" href="#tests" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Added threading support to <a class="reference internal" href="../topics/testing/tools.html#django.test.LiveServerTestCase" title="django.test.LiveServerTestCase"><code class="xref py py-class docutils literal notranslate"><span class="pre">LiveServerTestCase</span></code></a>.</li>
<li>Added settings that allow customizing the test tablespace parameters for
Oracle: <a class="reference internal" href="../ref/settings.html#std:setting-DATAFILE_SIZE"><code class="xref std std-setting docutils literal notranslate"><span class="pre">DATAFILE_SIZE</span></code></a>, <a class="reference internal" href="../ref/settings.html#std:setting-DATAFILE_TMP_SIZE"><code class="xref std std-setting docutils literal notranslate"><span class="pre">DATAFILE_TMP_SIZE</span></code></a>,
<a class="reference internal" href="../ref/settings.html#std:setting-DATAFILE_EXTSIZE"><code class="xref std std-setting docutils literal notranslate"><span class="pre">DATAFILE_EXTSIZE</span></code></a>, and <a class="reference internal" href="../ref/settings.html#std:setting-DATAFILE_TMP_EXTSIZE"><code class="xref std std-setting docutils literal notranslate"><span class="pre">DATAFILE_TMP_EXTSIZE</span></code></a>.</li>
</ul>
</div>
<div class="section" id="s-validators">
<span id="validators"></span><h4>Validators<a class="headerlink" href="#validators" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>The new <a class="reference internal" href="../ref/validators.html#django.core.validators.ProhibitNullCharactersValidator" title="django.core.validators.ProhibitNullCharactersValidator"><code class="xref py py-class docutils literal notranslate"><span class="pre">ProhibitNullCharactersValidator</span></code></a> disallows the null
character in the input of the <a class="reference internal" href="../ref/forms/fields.html#django.forms.CharField" title="django.forms.CharField"><code class="xref py py-class docutils literal notranslate"><span class="pre">CharField</span></code></a> form field
and its subclasses. Null character input was observed from vulnerability
scanning tools. Most databases silently discard null characters, but
psycopg2 2.7+ raises an exception when trying to save a null character to
a char/text field with PostgreSQL.</li>
</ul>
</div>
</div>
</div>
<div class="section" id="s-backwards-incompatible-changes-in-2-0">
<span id="s-backwards-incompatible-2-0"></span><span id="backwards-incompatible-changes-in-2-0"></span><span id="backwards-incompatible-2-0"></span><h2>Backwards incompatible changes in 2.0<a class="headerlink" href="#backwards-incompatible-changes-in-2-0" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-removed-support-for-bytestrings-in-some-places">
<span id="removed-support-for-bytestrings-in-some-places"></span><h3>Removed support for bytestrings in some places<a class="headerlink" href="#removed-support-for-bytestrings-in-some-places" title="Permalink to this headline">¶</a></h3>
<p>To support native Python 2 strings, older Django versions had to accept both
bytestrings and unicode strings. Now that Python 2 support is dropped,
bytestrings should only be encountered around input/output boundaries (handling
of binary fields or HTTP streams, for example). You might have to update your
code to limit bytestring usage to a minimum, as Django no longer accepts
bytestrings in certain code paths. Python’s <a class="reference external" href="https://docs.python.org/3/using/cmdline.html#cmdoption-b" title="(in Python v3.8)"><code class="xref std std-option docutils literal notranslate"><span class="pre">-b</span></code></a> option may help detect
that mistake in your code.</p>
<p>For example, <code class="docutils literal notranslate"><span class="pre">reverse()</span></code> now uses <code class="docutils literal notranslate"><span class="pre">str()</span></code> instead of <code class="docutils literal notranslate"><span class="pre">force_text()</span></code> to
coerce the <code class="docutils literal notranslate"><span class="pre">args</span></code> and <code class="docutils literal notranslate"><span class="pre">kwargs</span></code> it receives, prior to their placement in
the URL. For bytestrings, this creates a string with an undesired <code class="docutils literal notranslate"><span class="pre">b</span></code> prefix
as well as additional quotes (<code class="docutils literal notranslate"><span class="pre">str(b'foo')</span></code> is <code class="docutils literal notranslate"><span class="pre">&quot;b'foo'&quot;</span></code>). To adapt, call
<code class="docutils literal notranslate"><span class="pre">decode()</span></code> on the bytestring before passing it to <code class="docutils literal notranslate"><span class="pre">reverse()</span></code>.</p>
</div>
<div class="section" id="s-database-backend-api">
<span id="database-backend-api"></span><h3>Database backend API<a class="headerlink" href="#database-backend-api" title="Permalink to this headline">¶</a></h3>
<p>This section describes changes that may be needed in third-party database
backends.</p>
<ul class="simple">
<li>The <code class="docutils literal notranslate"><span class="pre">DatabaseOperations.datetime_cast_date_sql()</span></code>,
<code class="docutils literal notranslate"><span class="pre">datetime_cast_time_sql()</span></code>, <code class="docutils literal notranslate"><span class="pre">datetime_trunc_sql()</span></code>,
<code class="docutils literal notranslate"><span class="pre">datetime_extract_sql()</span></code>, and <code class="docutils literal notranslate"><span class="pre">date_interval_sql()</span></code> methods now return
only the SQL to perform the operation instead of SQL and a list of
parameters.</li>
<li>Third-party database backends should add a <code class="docutils literal notranslate"><span class="pre">DatabaseWrapper.display_name</span></code>
attribute with the name of the database that your backend works with. Django
may use it in various messages, such as in system checks.</li>
<li>The first argument of <code class="docutils literal notranslate"><span class="pre">SchemaEditor._alter_column_type_sql()</span></code> is now
<code class="docutils literal notranslate"><span class="pre">model</span></code> rather than <code class="docutils literal notranslate"><span class="pre">table</span></code>.</li>
<li>The first argument of <code class="docutils literal notranslate"><span class="pre">SchemaEditor._create_index_name()</span></code> is now
<code class="docutils literal notranslate"><span class="pre">table_name</span></code> rather than <code class="docutils literal notranslate"><span class="pre">model</span></code>.</li>
<li>To enable <code class="docutils literal notranslate"><span class="pre">FOR</span> <span class="pre">UPDATE</span> <span class="pre">OF</span></code> support, set
<code class="docutils literal notranslate"><span class="pre">DatabaseFeatures.has_select_for_update_of</span> <span class="pre">=</span> <span class="pre">True</span></code>. If the database
requires that the arguments to <code class="docutils literal notranslate"><span class="pre">OF</span></code> be columns rather than tables, set
<code class="docutils literal notranslate"><span class="pre">DatabaseFeatures.select_for_update_of_column</span> <span class="pre">=</span> <span class="pre">True</span></code>.</li>
<li>To enable support for <a class="reference internal" href="../ref/models/expressions.html#django.db.models.expressions.Window" title="django.db.models.expressions.Window"><code class="xref py py-class docutils literal notranslate"><span class="pre">Window</span></code></a>
expressions, set <code class="docutils literal notranslate"><span class="pre">DatabaseFeatures.supports_over_clause</span></code> to <code class="docutils literal notranslate"><span class="pre">True</span></code>. You
may need to customize the <code class="docutils literal notranslate"><span class="pre">DatabaseOperations.window_start_rows_start_end()</span></code>
and/or <code class="docutils literal notranslate"><span class="pre">window_start_range_start_end()</span></code> methods.</li>
<li>Third-party database backends should add a
<code class="docutils literal notranslate"><span class="pre">DatabaseOperations.cast_char_field_without_max_length</span></code> attribute with the
database data type that will be used in the
<a class="reference internal" href="../ref/models/database-functions.html#django.db.models.functions.Cast" title="django.db.models.functions.Cast"><code class="xref py py-class docutils literal notranslate"><span class="pre">Cast</span></code></a> function for a <code class="docutils literal notranslate"><span class="pre">CharField</span></code> if the
<code class="docutils literal notranslate"><span class="pre">max_length</span></code> argument isn’t provided.</li>
<li>The first argument of <code class="docutils literal notranslate"><span class="pre">DatabaseCreation._clone_test_db()</span></code> and
<code class="docutils literal notranslate"><span class="pre">get_test_db_clone_settings()</span></code> is now <code class="docutils literal notranslate"><span class="pre">suffix</span></code> rather
than <code class="docutils literal notranslate"><span class="pre">number</span></code> (in case you want to rename the signatures in your backend
for consistency). <code class="docutils literal notranslate"><span class="pre">django.test</span></code> also now passes those values as strings
rather than as integers.</li>
<li>Third-party database backends should add a
<code class="docutils literal notranslate"><span class="pre">DatabaseIntrospection.get_sequences()</span></code> method based on the stub in
<code class="docutils literal notranslate"><span class="pre">BaseDatabaseIntrospection</span></code>.</li>
</ul>
</div>
<div class="section" id="s-dropped-support-for-oracle-11-2">
<span id="dropped-support-for-oracle-11-2"></span><h3>Dropped support for Oracle 11.2<a class="headerlink" href="#dropped-support-for-oracle-11-2" title="Permalink to this headline">¶</a></h3>
<p>The end of upstream support for Oracle 11.2 is Dec. 2020. Django 1.11 will be
supported until April 2020 which almost reaches this date. Django 2.0
officially supports Oracle 12.1+.</p>
</div>
<div class="section" id="s-default-mysql-isolation-level-is-read-committed">
<span id="default-mysql-isolation-level-is-read-committed"></span><h3>Default MySQL isolation level is read committed<a class="headerlink" href="#default-mysql-isolation-level-is-read-committed" title="Permalink to this headline">¶</a></h3>
<p>MySQL’s default isolation level, repeatable read, may cause data loss in
typical Django usage. To prevent that and for consistency with other databases,
the default isolation level is now read committed. You can use the
<a class="reference internal" href="../ref/settings.html#std:setting-DATABASES"><code class="xref std std-setting docutils literal notranslate"><span class="pre">DATABASES</span></code></a> setting to <a class="reference internal" href="../ref/databases.html#mysql-isolation-level"><span class="std std-ref">use a different isolation level</span></a>, if needed.</p>
</div>
<div class="section" id="s-abstractuser-last-name-max-length-increased-to-150">
<span id="abstractuser-last-name-max-length-increased-to-150"></span><h3><a class="reference internal" href="../ref/contrib/auth.html#django.contrib.auth.models.User.last_name" title="django.contrib.auth.models.User.last_name"><code class="xref py py-attr docutils literal notranslate"><span class="pre">AbstractUser.last_name</span></code></a> <code class="docutils literal notranslate"><span class="pre">max_length</span></code> increased to 150<a class="headerlink" href="#abstractuser-last-name-max-length-increased-to-150" title="Permalink to this headline">¶</a></h3>
<p>A migration for <a class="reference internal" href="../ref/contrib/auth.html#django.contrib.auth.models.User.last_name" title="django.contrib.auth.models.User.last_name"><code class="xref py py-attr docutils literal notranslate"><span class="pre">django.contrib.auth.models.User.last_name</span></code></a> is included.
If you have a custom user model inheriting from <code class="docutils literal notranslate"><span class="pre">AbstractUser</span></code>, you’ll need
to generate and apply a database migration for your user model.</p>
<p>If you want to preserve the 30 character limit for last names, use a custom
form:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.contrib.auth.forms</span> <span class="k">import</span> <span class="n">UserChangeForm</span>

<span class="k">class</span> <span class="nc">MyUserChangeForm</span><span class="p">(</span><span class="n">UserChangeForm</span><span class="p">):</span>
    <span class="n">last_name</span> <span class="o">=</span> <span class="n">forms</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mi">30</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
</pre></div>
</div>
<p>If you wish to keep this restriction in the admin when editing users, set
<code class="docutils literal notranslate"><span class="pre">UserAdmin.form</span></code> to use this form:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.contrib.auth.admin</span> <span class="k">import</span> <span class="n">UserAdmin</span>
<span class="kn">from</span> <span class="nn">django.contrib.auth.models</span> <span class="k">import</span> <span class="n">User</span>

<span class="k">class</span> <span class="nc">MyUserAdmin</span><span class="p">(</span><span class="n">UserAdmin</span><span class="p">):</span>
    <span class="n">form</span> <span class="o">=</span> <span class="n">MyUserChangeForm</span>

<span class="n">admin</span><span class="o">.</span><span class="n">site</span><span class="o">.</span><span class="n">unregister</span><span class="p">(</span><span class="n">User</span><span class="p">)</span>
<span class="n">admin</span><span class="o">.</span><span class="n">site</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">User</span><span class="p">,</span> <span class="n">MyUserAdmin</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="s-queryset-reverse-and-last-are-prohibited-after-slicing">
<span id="queryset-reverse-and-last-are-prohibited-after-slicing"></span><h3><code class="docutils literal notranslate"><span class="pre">QuerySet.reverse()</span></code> and <code class="docutils literal notranslate"><span class="pre">last()</span></code> are prohibited after slicing<a class="headerlink" href="#queryset-reverse-and-last-are-prohibited-after-slicing" title="Permalink to this headline">¶</a></h3>
<p>Calling <code class="docutils literal notranslate"><span class="pre">QuerySet.reverse()</span></code> or <code class="docutils literal notranslate"><span class="pre">last()</span></code> on a sliced queryset leads to
unexpected results due to the slice being applied after reordering. This is
now prohibited, e.g.:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Model</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">()[:</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">reverse</span><span class="p">()</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">TypeError</span>: <span class="n">Cannot reverse a query once a slice has been taken.</span>
</pre></div>
</div>
</div>
<div class="section" id="s-form-fields-no-longer-accept-optional-arguments-as-positional-arguments">
<span id="form-fields-no-longer-accept-optional-arguments-as-positional-arguments"></span><h3>Form fields no longer accept optional arguments as positional arguments<a class="headerlink" href="#form-fields-no-longer-accept-optional-arguments-as-positional-arguments" title="Permalink to this headline">¶</a></h3>
<p>To help prevent runtime errors due to incorrect ordering of form field
arguments, optional arguments of built-in form fields are no longer accepted
as positional arguments. For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">forms</span><span class="o">.</span><span class="n">IntegerField</span><span class="p">(</span><span class="mi">25</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
</pre></div>
</div>
<p>raises an exception and should be replaced with:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">forms</span><span class="o">.</span><span class="n">IntegerField</span><span class="p">(</span><span class="n">max_value</span><span class="o">=</span><span class="mi">25</span><span class="p">,</span> <span class="n">min_value</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="s-call-command-validates-the-options-it-receives">
<span id="call-command-validates-the-options-it-receives"></span><h3><code class="docutils literal notranslate"><span class="pre">call_command()</span></code> validates the options it receives<a class="headerlink" href="#call-command-validates-the-options-it-receives" title="Permalink to this headline">¶</a></h3>
<p><code class="docutils literal notranslate"><span class="pre">call_command()</span></code> now validates that the argument parser of the command being
called defines all of the options passed to <code class="docutils literal notranslate"><span class="pre">call_command()</span></code>.</p>
<p>For custom management commands that use options not created using
<code class="docutils literal notranslate"><span class="pre">parser.add_argument()</span></code>, add a <code class="docutils literal notranslate"><span class="pre">stealth_options</span></code> attribute on the command:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">MyCommand</span><span class="p">(</span><span class="n">BaseCommand</span><span class="p">):</span>
    <span class="n">stealth_options</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;option_name&#39;</span><span class="p">,</span> <span class="o">...</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="s-indexes-no-longer-accept-positional-arguments">
<span id="indexes-no-longer-accept-positional-arguments"></span><h3>Indexes no longer accept positional arguments<a class="headerlink" href="#indexes-no-longer-accept-positional-arguments" title="Permalink to this headline">¶</a></h3>
<p>For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">models</span><span class="o">.</span><span class="n">Index</span><span class="p">([</span><span class="s1">&#39;headline&#39;</span><span class="p">,</span> <span class="s1">&#39;-pub_date&#39;</span><span class="p">],</span> <span class="s1">&#39;index_name&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>raises an exception and should be replaced with:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">models</span><span class="o">.</span><span class="n">Index</span><span class="p">(</span><span class="n">fields</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;headline&#39;</span><span class="p">,</span> <span class="s1">&#39;-pub_date&#39;</span><span class="p">],</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;index_name&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="s-foreign-key-constraints-are-now-enabled-on-sqlite">
<span id="foreign-key-constraints-are-now-enabled-on-sqlite"></span><h3>Foreign key constraints are now enabled on SQLite<a class="headerlink" href="#foreign-key-constraints-are-now-enabled-on-sqlite" title="Permalink to this headline">¶</a></h3>
<p>This will appear as a backwards-incompatible change (<code class="docutils literal notranslate"><span class="pre">IntegrityError:</span>
<span class="pre">FOREIGN</span> <span class="pre">KEY</span> <span class="pre">constraint</span> <span class="pre">failed</span></code>) if attempting to save an existing model
instance that’s violating a foreign key constraint.</p>
<p>Foreign keys are now created with <code class="docutils literal notranslate"><span class="pre">DEFERRABLE</span> <span class="pre">INITIALLY</span> <span class="pre">DEFERRED</span></code> instead of
<code class="docutils literal notranslate"><span class="pre">DEFERRABLE</span> <span class="pre">IMMEDIATE</span></code>. Thus, tables may need to be rebuilt to recreate
foreign keys with the new definition, particularly if you’re using a pattern
like this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.db</span> <span class="k">import</span> <span class="n">transaction</span>

<span class="k">with</span> <span class="n">transaction</span><span class="o">.</span><span class="n">atomic</span><span class="p">():</span>
    <span class="n">Book</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="n">author_id</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
    <span class="n">Author</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<p>If you don’t recreate the foreign key as <code class="docutils literal notranslate"><span class="pre">DEFERRED</span></code>, the first <code class="docutils literal notranslate"><span class="pre">create()</span></code>
would fail now that foreign key constraints are enforced.</p>
<p>Backup your database first! After upgrading to Django 2.0, you can then
rebuild tables using a script similar to this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.apps</span> <span class="k">import</span> <span class="n">apps</span>
<span class="kn">from</span> <span class="nn">django.db</span> <span class="k">import</span> <span class="n">connection</span>

<span class="k">for</span> <span class="n">app</span> <span class="ow">in</span> <span class="n">apps</span><span class="o">.</span><span class="n">get_app_configs</span><span class="p">():</span>
    <span class="k">for</span> <span class="n">model</span> <span class="ow">in</span> <span class="n">app</span><span class="o">.</span><span class="n">get_models</span><span class="p">(</span><span class="n">include_auto_created</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">model</span><span class="o">.</span><span class="n">_meta</span><span class="o">.</span><span class="n">managed</span> <span class="ow">and</span> <span class="ow">not</span> <span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">_meta</span><span class="o">.</span><span class="n">proxy</span> <span class="ow">or</span> <span class="n">model</span><span class="o">.</span><span class="n">_meta</span><span class="o">.</span><span class="n">swapped</span><span class="p">):</span>
            <span class="k">for</span> <span class="n">base</span> <span class="ow">in</span> <span class="n">model</span><span class="o">.</span><span class="vm">__bases__</span><span class="p">:</span>
                <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">base</span><span class="p">,</span> <span class="s1">&#39;_meta&#39;</span><span class="p">):</span>
                    <span class="n">base</span><span class="o">.</span><span class="n">_meta</span><span class="o">.</span><span class="n">local_many_to_many</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">model</span><span class="o">.</span><span class="n">_meta</span><span class="o">.</span><span class="n">local_many_to_many</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">with</span> <span class="n">connection</span><span class="o">.</span><span class="n">schema_editor</span><span class="p">()</span> <span class="k">as</span> <span class="n">editor</span><span class="p">:</span>
                <span class="n">editor</span><span class="o">.</span><span class="n">_remake_table</span><span class="p">(</span><span class="n">model</span><span class="p">)</span>
</pre></div>
</div>
<p>This script hasn’t received extensive testing and needs adaption for various
cases such as multiple databases. Feel free to contribute improvements.</p>
<p>In addition, because of a table alteration limitation of SQLite, it’s prohibited
to perform <a class="reference internal" href="../ref/migration-operations.html#django.db.migrations.operations.RenameModel" title="django.db.migrations.operations.RenameModel"><code class="xref py py-class docutils literal notranslate"><span class="pre">RenameModel</span></code></a> and
<a class="reference internal" href="../ref/migration-operations.html#django.db.migrations.operations.RenameField" title="django.db.migrations.operations.RenameField"><code class="xref py py-class docutils literal notranslate"><span class="pre">RenameField</span></code></a> operations on models or
fields referenced by other models in a transaction. In order to allow migrations
containing these operations to be applied, you must set the
<code class="docutils literal notranslate"><span class="pre">Migration.atomic</span></code> attribute to <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p>
</div>
<div class="section" id="s-miscellaneous">
<span id="miscellaneous"></span><h3>Miscellaneous<a class="headerlink" href="#miscellaneous" title="Permalink to this headline">¶</a></h3>
<ul>
<li><p class="first">The <code class="docutils literal notranslate"><span class="pre">SessionAuthenticationMiddleware</span></code> class is removed. It provided no
functionality since session authentication is unconditionally enabled in
Django 1.10.</p>
</li>
<li><p class="first">The default HTTP error handlers (<code class="docutils literal notranslate"><span class="pre">handler404</span></code>, etc.) are now callables
instead of dotted Python path strings. Django favors callable references
since they provide better performance and debugging experience.</p>
</li>
<li><p class="first"><a class="reference internal" href="../ref/class-based-views/base.html#django.views.generic.base.RedirectView" title="django.views.generic.base.RedirectView"><code class="xref py py-class docutils literal notranslate"><span class="pre">RedirectView</span></code></a> no longer silences
<code class="docutils literal notranslate"><span class="pre">NoReverseMatch</span></code> if the <code class="docutils literal notranslate"><span class="pre">pattern_name</span></code> doesn’t exist.</p>
</li>
<li><p class="first">When <a class="reference internal" href="../ref/settings.html#std:setting-USE_L10N"><code class="xref std std-setting docutils literal notranslate"><span class="pre">USE_L10N</span></code></a> is off, <a class="reference internal" href="../ref/forms/fields.html#django.forms.FloatField" title="django.forms.FloatField"><code class="xref py py-class docutils literal notranslate"><span class="pre">FloatField</span></code></a> and
<a class="reference internal" href="../ref/forms/fields.html#django.forms.DecimalField" title="django.forms.DecimalField"><code class="xref py py-class docutils literal notranslate"><span class="pre">DecimalField</span></code></a> now respect <a class="reference internal" href="../ref/settings.html#std:setting-DECIMAL_SEPARATOR"><code class="xref std std-setting docutils literal notranslate"><span class="pre">DECIMAL_SEPARATOR</span></code></a>
and <a class="reference internal" href="../ref/settings.html#std:setting-THOUSAND_SEPARATOR"><code class="xref std std-setting docutils literal notranslate"><span class="pre">THOUSAND_SEPARATOR</span></code></a> during validation. For example, with the
settings:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">USE_L10N</span> <span class="o">=</span> <span class="kc">False</span>
<span class="n">USE_THOUSAND_SEPARATOR</span> <span class="o">=</span> <span class="kc">True</span>
<span class="n">DECIMAL_SEPARATOR</span> <span class="o">=</span> <span class="s1">&#39;,&#39;</span>
<span class="n">THOUSAND_SEPARATOR</span> <span class="o">=</span> <span class="s1">&#39;.&#39;</span>
</pre></div>
</div>
<p>an input of <code class="docutils literal notranslate"><span class="pre">&quot;1.345&quot;</span></code> is now converted to <code class="docutils literal notranslate"><span class="pre">1345</span></code> instead of <code class="docutils literal notranslate"><span class="pre">1.345</span></code>.</p>
</li>
<li><p class="first">Subclasses of <a class="reference internal" href="../topics/auth/customizing.html#django.contrib.auth.models.AbstractBaseUser" title="django.contrib.auth.models.AbstractBaseUser"><code class="xref py py-class docutils literal notranslate"><span class="pre">AbstractBaseUser</span></code></a> are no
longer required to implement <code class="docutils literal notranslate"><span class="pre">get_short_name()</span></code> and <code class="docutils literal notranslate"><span class="pre">get_full_name()</span></code>.
(The base implementations that raise <code class="docutils literal notranslate"><span class="pre">NotImplementedError</span></code> are removed.)
<code class="docutils literal notranslate"><span class="pre">django.contrib.admin</span></code> uses these methods if implemented but doesn’t
require them. Third-party apps that use these methods may want to adopt a
similar approach.</p>
</li>
<li><p class="first">The <code class="docutils literal notranslate"><span class="pre">FIRST_DAY_OF_WEEK</span></code> and <code class="docutils literal notranslate"><span class="pre">NUMBER_GROUPING</span></code> format settings are now
kept as integers in JavaScript and JSON i18n view outputs.</p>
</li>
<li><p class="first"><a class="reference internal" href="../topics/testing/tools.html#django.test.TransactionTestCase.assertNumQueries" title="django.test.TransactionTestCase.assertNumQueries"><code class="xref py py-meth docutils literal notranslate"><span class="pre">assertNumQueries()</span></code></a> now ignores
connection configuration queries. Previously, if a test opened a new database
connection, those queries could be included as part of the
<code class="docutils literal notranslate"><span class="pre">assertNumQueries()</span></code> count.</p>
</li>
<li><p class="first">The default size of the Oracle test tablespace is increased from 20M to 50M
and the default autoextend size is increased from 10M to 25M.</p>
</li>
<li><p class="first">To improve performance when streaming large result sets from the database,
<a class="reference internal" href="../ref/models/querysets.html#django.db.models.query.QuerySet.iterator" title="django.db.models.query.QuerySet.iterator"><code class="xref py py-meth docutils literal notranslate"><span class="pre">QuerySet.iterator()</span></code></a> now fetches 2000 rows at a time instead of 100.
The old behavior can be restored using the <code class="docutils literal notranslate"><span class="pre">chunk_size</span></code> parameter. For
example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Book</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">iterator</span><span class="p">(</span><span class="n">chunk_size</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p class="first">Providing unknown package names in the <code class="docutils literal notranslate"><span class="pre">packages</span></code> argument of the
<a class="reference internal" href="../topics/i18n/translation.html#django.views.i18n.JavaScriptCatalog" title="django.views.i18n.JavaScriptCatalog"><code class="xref py py-class docutils literal notranslate"><span class="pre">JavaScriptCatalog</span></code></a> view now raises <code class="docutils literal notranslate"><span class="pre">ValueError</span></code>
instead of passing silently.</p>
</li>
<li><p class="first">A model instance’s primary key now appears in the default <code class="docutils literal notranslate"><span class="pre">Model.__str__()</span></code>
method, e.g. <code class="docutils literal notranslate"><span class="pre">Question</span> <span class="pre">object</span> <span class="pre">(1)</span></code>.</p>
</li>
<li><p class="first"><code class="docutils literal notranslate"><span class="pre">makemigrations</span></code> now detects changes to the model field <code class="docutils literal notranslate"><span class="pre">limit_choices_to</span></code>
option. Add this to your existing migrations or accept an auto-generated
migration for fields that use it.</p>
</li>
<li><p class="first">Performing queries that require <a class="reference internal" href="../ref/contrib/gis/tutorial.html#automatic-spatial-transformations"><span class="std std-ref">automatic spatial transformations</span></a> now raises <code class="docutils literal notranslate"><span class="pre">NotImplementedError</span></code>
on MySQL instead of silently using non-transformed geometries.</p>
</li>
<li><p class="first"><code class="docutils literal notranslate"><span class="pre">django.core.exceptions.DjangoRuntimeWarning</span></code> is removed. It was only used
in the cache backend as an intermediate class in <code class="docutils literal notranslate"><span class="pre">CacheKeyWarning</span></code>’s
inheritance of <code class="docutils literal notranslate"><span class="pre">RuntimeWarning</span></code>.</p>
</li>
<li><p class="first">Renamed <code class="docutils literal notranslate"><span class="pre">BaseExpression._output_field</span></code> to <code class="docutils literal notranslate"><span class="pre">output_field</span></code>. You may need
to update custom expressions.</p>
</li>
<li><p class="first">In older versions, forms and formsets combine their <code class="docutils literal notranslate"><span class="pre">Media</span></code> with widget
<code class="docutils literal notranslate"><span class="pre">Media</span></code> by concatenating the two. The combining now tries to <a class="reference internal" href="../topics/forms/media.html#form-media-asset-order"><span class="std std-ref">preserve
the relative order of elements in each list</span></a>.
<code class="docutils literal notranslate"><span class="pre">MediaOrderConflictWarning</span></code> is issued if the order can’t be preserved.</p>
</li>
<li><p class="first"><code class="docutils literal notranslate"><span class="pre">django.contrib.gis.gdal.OGRException</span></code> is removed. It’s been an alias for
<code class="docutils literal notranslate"><span class="pre">GDALException</span></code> since Django 1.8.</p>
</li>
<li><p class="first">Support for GEOS 3.3.x is dropped.</p>
</li>
<li><p class="first">The way data is selected for <code class="docutils literal notranslate"><span class="pre">GeometryField</span></code> is changed to improve
performance, and in raw SQL queries, those fields must now be wrapped in
<code class="docutils literal notranslate"><span class="pre">connection.ops.select</span></code>. See the <a class="reference internal" href="../ref/contrib/gis/tutorial.html#gis-raw-sql"><span class="std std-ref">Raw queries note</span></a> in
the GIS tutorial for an example.</p>
</li>
</ul>
</div>
</div>
<div class="section" id="s-features-deprecated-in-2-0">
<span id="s-deprecated-features-2-0"></span><span id="features-deprecated-in-2-0"></span><span id="deprecated-features-2-0"></span><h2>Features deprecated in 2.0<a class="headerlink" href="#features-deprecated-in-2-0" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-context-argument-of-field-from-db-value-and-expression-convert-value">
<span id="context-argument-of-field-from-db-value-and-expression-convert-value"></span><h3><code class="docutils literal notranslate"><span class="pre">context</span></code> argument of <code class="docutils literal notranslate"><span class="pre">Field.from_db_value()</span></code> and <code class="docutils literal notranslate"><span class="pre">Expression.convert_value()</span></code><a class="headerlink" href="#context-argument-of-field-from-db-value-and-expression-convert-value" title="Permalink to this headline">¶</a></h3>
<p>The <code class="docutils literal notranslate"><span class="pre">context</span></code> argument of <code class="docutils literal notranslate"><span class="pre">Field.from_db_value()</span></code> and
<code class="docutils literal notranslate"><span class="pre">Expression.convert_value()</span></code> is unused as it’s always an empty dictionary.
The signature of both methods is now:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">connection</span><span class="p">)</span>
</pre></div>
</div>
<p>instead of:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">connection</span><span class="p">,</span> <span class="n">context</span><span class="p">)</span>
</pre></div>
</div>
<p>Support for the old signature in custom fields and expressions remains until
Django 3.0.</p>
</div>
<div class="section" id="s-id1">
<span id="id1"></span><h3>Miscellaneous<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>The <code class="docutils literal notranslate"><span class="pre">django.db.backends.postgresql_psycopg2</span></code> module is deprecated in favor
of <code class="docutils literal notranslate"><span class="pre">django.db.backends.postgresql</span></code>. It’s been an alias since Django 1.9.
This only affects code that imports from the module directly. The
<code class="docutils literal notranslate"><span class="pre">DATABASES</span></code> setting can still use
<code class="docutils literal notranslate"><span class="pre">'django.db.backends.postgresql_psycopg2'</span></code>, though you can simplify that by
using the <code class="docutils literal notranslate"><span class="pre">'django.db.backends.postgresql'</span></code> name added in Django 1.9.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.shortcuts.render_to_response()</span></code> is deprecated in favor of
<a class="reference internal" href="../topics/http/shortcuts.html#django.shortcuts.render" title="django.shortcuts.render"><code class="xref py py-func docutils literal notranslate"><span class="pre">django.shortcuts.render()</span></code></a>. <code class="docutils literal notranslate"><span class="pre">render()</span></code> takes the same arguments
except that it also requires a <code class="docutils literal notranslate"><span class="pre">request</span></code>.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">DEFAULT_CONTENT_TYPE</span></code> setting is deprecated. It doesn’t interact well
with third-party apps and is obsolete since HTML5 has mostly superseded
XHTML.</li>
<li><code class="docutils literal notranslate"><span class="pre">HttpRequest.xreadlines()</span></code> is deprecated in favor of iterating over the
request.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">field_name</span></code> keyword argument to <a class="reference internal" href="../ref/models/querysets.html#django.db.models.query.QuerySet.earliest" title="django.db.models.query.QuerySet.earliest"><code class="xref py py-meth docutils literal notranslate"><span class="pre">QuerySet.earliest()</span></code></a> and
<a class="reference internal" href="../ref/models/querysets.html#django.db.models.query.QuerySet.latest" title="django.db.models.query.QuerySet.latest"><code class="xref py py-meth docutils literal notranslate"><span class="pre">QuerySet.latest()</span></code></a> is deprecated in favor of passing the field
names as arguments. Write <code class="docutils literal notranslate"><span class="pre">.earliest('pub_date')</span></code> instead of
<code class="docutils literal notranslate"><span class="pre">.earliest(field_name='pub_date')</span></code>.</li>
</ul>
</div>
</div>
<div class="section" id="s-features-removed-in-2-0">
<span id="s-removed-features-2-0"></span><span id="features-removed-in-2-0"></span><span id="removed-features-2-0"></span><h2>Features removed in 2.0<a class="headerlink" href="#features-removed-in-2-0" title="Permalink to this headline">¶</a></h2>
<p>These features have reached the end of their deprecation cycle and are removed
in Django 2.0.</p>
<p>See <a class="reference internal" href="1.9.html#deprecated-features-1-9"><span class="std std-ref">Features deprecated in 1.9</span></a> for details on these changes, including how
to remove usage of these features.</p>
<ul class="simple">
<li>The <code class="docutils literal notranslate"><span class="pre">weak</span></code> argument to <code class="docutils literal notranslate"><span class="pre">django.dispatch.signals.Signal.disconnect()</span></code> is
removed.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.db.backends.base.BaseDatabaseOperations.check_aggregate_support()</span></code>
is removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">django.forms.extras</span></code> package is removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">assignment_tag</span></code> helper is removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">host</span></code> argument to <code class="docutils literal notranslate"><span class="pre">SimpleTestCase.assertsRedirects()</span></code> is removed.
The compatibility layer which allows absolute URLs to be considered equal to
relative ones when the path is identical is also removed.</li>
<li><code class="docutils literal notranslate"><span class="pre">Field.rel</span></code> and <code class="docutils literal notranslate"><span class="pre">Field.remote_field.to</span></code> are removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">on_delete</span></code> argument for <code class="docutils literal notranslate"><span class="pre">ForeignKey</span></code> and <code class="docutils literal notranslate"><span class="pre">OneToOneField</span></code> is now
required in models and migrations. Consider squashing migrations so that you
have fewer of them to update.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.db.models.fields.add_lazy_relation()</span></code> is removed.</li>
<li>When time zone support is enabled, database backends that don’t support time
zones no longer convert aware datetimes to naive values in UTC anymore when
such values are passed as parameters to SQL queries executed outside of the
ORM, e.g. with <code class="docutils literal notranslate"><span class="pre">cursor.execute()</span></code>.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.contrib.auth.tests.utils.skipIfCustomUser()</span></code> is removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">GeoManager</span></code> and <code class="docutils literal notranslate"><span class="pre">GeoQuerySet</span></code> classes are removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">django.contrib.gis.geoip</span></code> module is removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">supports_recursion</span></code> check for template loaders is removed from:<ul>
<li><code class="docutils literal notranslate"><span class="pre">django.template.engine.Engine.find_template()</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">django.template.loader_tags.ExtendsNode.find_template()</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">django.template.loaders.base.Loader.supports_recursion()</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">django.template.loaders.cached.Loader.supports_recursion()</span></code></li>
</ul>
</li>
<li>The <code class="docutils literal notranslate"><span class="pre">load_template</span></code> and <code class="docutils literal notranslate"><span class="pre">load_template_sources</span></code> template loader methods
are removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">template_dirs</span></code> argument for template loaders is removed:<ul>
<li><code class="docutils literal notranslate"><span class="pre">django.template.loaders.base.Loader.get_template()</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">django.template.loaders.cached.Loader.cache_key()</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">django.template.loaders.cached.Loader.get_template()</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">django.template.loaders.cached.Loader.get_template_sources()</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">django.template.loaders.filesystem.Loader.get_template_sources()</span></code></li>
</ul>
</li>
<li><code class="docutils literal notranslate"><span class="pre">django.template.loaders.base.Loader.__call__()</span></code> is removed.</li>
<li>Support for custom error views that don’t accept an <code class="docutils literal notranslate"><span class="pre">exception</span></code> parameter
is removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">mime_type</span></code> attribute of <code class="docutils literal notranslate"><span class="pre">django.utils.feedgenerator.Atom1Feed</span></code> and
<code class="docutils literal notranslate"><span class="pre">django.utils.feedgenerator.RssFeed</span></code> is removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">app_name</span></code> argument to <code class="docutils literal notranslate"><span class="pre">include()</span></code> is removed.</li>
<li>Support for passing a 3-tuple (including <code class="docutils literal notranslate"><span class="pre">admin.site.urls</span></code>) as the first
argument to <code class="docutils literal notranslate"><span class="pre">include()</span></code> is removed.</li>
<li>Support for setting a URL instance namespace without an application namespace
is removed.</li>
<li><code class="docutils literal notranslate"><span class="pre">Field._get_val_from_obj()</span></code> is removed.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.template.loaders.eggs.Loader</span></code> is removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">current_app</span></code> parameter to the <code class="docutils literal notranslate"><span class="pre">contrib.auth</span></code> function-based views is
removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">callable_obj</span></code> keyword argument to
<code class="docutils literal notranslate"><span class="pre">SimpleTestCase.assertRaisesMessage()</span></code> is removed.</li>
<li>Support for the <code class="docutils literal notranslate"><span class="pre">allow_tags</span></code> attribute on <code class="docutils literal notranslate"><span class="pre">ModelAdmin</span></code> methods is
removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">enclosure</span></code> keyword argument to <code class="docutils literal notranslate"><span class="pre">SyndicationFeed.add_item()</span></code> is
removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">django.template.loader.LoaderOrigin</span></code> and
<code class="docutils literal notranslate"><span class="pre">django.template.base.StringOrigin</span></code> aliases for
<code class="docutils literal notranslate"><span class="pre">django.template.base.Origin</span></code> are removed.</li>
</ul>
<p>See <a class="reference internal" href="1.10.html#deprecated-features-1-10"><span class="std std-ref">Features deprecated in 1.10</span></a> for details on these changes.</p>
<ul class="simple">
<li>The <code class="docutils literal notranslate"><span class="pre">makemigrations</span> <span class="pre">--exit</span></code> option is removed.</li>
<li>Support for direct assignment to a reverse foreign key or many-to-many
relation is removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">get_srid()</span></code> and <code class="docutils literal notranslate"><span class="pre">set_srid()</span></code> methods of
<code class="docutils literal notranslate"><span class="pre">django.contrib.gis.geos.GEOSGeometry</span></code> are removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">get_x()</span></code>, <code class="docutils literal notranslate"><span class="pre">set_x()</span></code>, <code class="docutils literal notranslate"><span class="pre">get_y()</span></code>, <code class="docutils literal notranslate"><span class="pre">set_y()</span></code>, <code class="docutils literal notranslate"><span class="pre">get_z()</span></code>, and
<code class="docutils literal notranslate"><span class="pre">set_z()</span></code> methods of <code class="docutils literal notranslate"><span class="pre">django.contrib.gis.geos.Point</span></code> are removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">get_coords()</span></code> and <code class="docutils literal notranslate"><span class="pre">set_coords()</span></code> methods of
<code class="docutils literal notranslate"><span class="pre">django.contrib.gis.geos.Point</span></code> are removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">cascaded_union</span></code> property of <code class="docutils literal notranslate"><span class="pre">django.contrib.gis.geos.MultiPolygon</span></code>
is removed.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.utils.functional.allow_lazy()</span></code> is removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">shell</span> <span class="pre">--plain</span></code> option is removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">django.core.urlresolvers</span></code> module is removed in favor of its new
location, <code class="docutils literal notranslate"><span class="pre">django.urls</span></code>.</li>
<li><code class="docutils literal notranslate"><span class="pre">CommaSeparatedIntegerField</span></code> is removed, except for support in historical
migrations.</li>
<li>The template <code class="docutils literal notranslate"><span class="pre">Context.has_key()</span></code> method is removed.</li>
<li>Support for the <code class="docutils literal notranslate"><span class="pre">django.core.files.storage.Storage.accessed_time()</span></code>,
<code class="docutils literal notranslate"><span class="pre">created_time()</span></code>, and <code class="docutils literal notranslate"><span class="pre">modified_time()</span></code> methods is removed.</li>
<li>Support for query lookups using the model name when
<code class="docutils literal notranslate"><span class="pre">Meta.default_related_name</span></code> is set is removed.</li>
<li>The MySQL <code class="docutils literal notranslate"><span class="pre">__search</span></code> lookup is removed.</li>
<li>The shim for supporting custom related manager classes without a
<code class="docutils literal notranslate"><span class="pre">_apply_rel_filters()</span></code> method is removed.</li>
<li>Using <code class="docutils literal notranslate"><span class="pre">User.is_authenticated()</span></code> and <code class="docutils literal notranslate"><span class="pre">User.is_anonymous()</span></code> as methods
rather than properties is no longer supported.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">Model._meta.virtual_fields</span></code> attribute is removed.</li>
<li>The keyword arguments <code class="docutils literal notranslate"><span class="pre">virtual_only</span></code> in <code class="docutils literal notranslate"><span class="pre">Field.contribute_to_class()</span></code> and
<code class="docutils literal notranslate"><span class="pre">virtual</span></code> in <code class="docutils literal notranslate"><span class="pre">Model._meta.add_field()</span></code> are removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">javascript_catalog()</span></code> and <code class="docutils literal notranslate"><span class="pre">json_catalog()</span></code> views are removed.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.contrib.gis.utils.precision_wkt()</span></code> is removed.</li>
<li>In multi-table inheritance, implicit promotion of a <code class="docutils literal notranslate"><span class="pre">OneToOneField</span></code> to a
<code class="docutils literal notranslate"><span class="pre">parent_link</span></code> is removed.</li>
<li>Support for <code class="docutils literal notranslate"><span class="pre">Widget._format_value()</span></code> is removed.</li>
<li><code class="docutils literal notranslate"><span class="pre">FileField</span></code> methods <code class="docutils literal notranslate"><span class="pre">get_directory_name()</span></code> and <code class="docutils literal notranslate"><span class="pre">get_filename()</span></code> are
removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">mark_for_escaping()</span></code> function and the classes it uses: <code class="docutils literal notranslate"><span class="pre">EscapeData</span></code>,
<code class="docutils literal notranslate"><span class="pre">EscapeBytes</span></code>, <code class="docutils literal notranslate"><span class="pre">EscapeText</span></code>, <code class="docutils literal notranslate"><span class="pre">EscapeString</span></code>, and <code class="docutils literal notranslate"><span class="pre">EscapeUnicode</span></code> are
removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">escape</span></code> filter now uses <code class="docutils literal notranslate"><span class="pre">django.utils.html.conditional_escape()</span></code>.</li>
<li><code class="docutils literal notranslate"><span class="pre">Manager.use_for_related_fields</span></code> is removed.</li>
<li>Model <code class="docutils literal notranslate"><span class="pre">Manager</span></code> inheritance follows MRO inheritance rules. The requirement
to use <code class="docutils literal notranslate"><span class="pre">Meta.manager_inheritance_from_future</span></code> to opt-in to the behavior is
removed.</li>
<li>Support for old-style middleware using <code class="docutils literal notranslate"><span class="pre">settings.MIDDLEWARE_CLASSES</span></code> is
removed.</li>
</ul>
</div>
</div>


          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Django 2.0 release notes</a><ul>
<li><a class="reference internal" href="#python-compatibility">Python compatibility</a></li>
<li><a class="reference internal" href="#third-party-library-support-for-older-version-of-django">Third-party library support for older version of Django</a></li>
<li><a class="reference internal" href="#what-s-new-in-django-2-0">What’s new in Django 2.0</a><ul>
<li><a class="reference internal" href="#simplified-url-routing-syntax">Simplified URL routing syntax</a></li>
<li><a class="reference internal" href="#mobile-friendly-contrib-admin">Mobile-friendly <code class="docutils literal notranslate"><span class="pre">contrib.admin</span></code></a></li>
<li><a class="reference internal" href="#window-expressions">Window expressions</a></li>
<li><a class="reference internal" href="#minor-features">Minor features</a><ul>
<li><a class="reference internal" href="#django-contrib-admin"><code class="docutils literal notranslate"><span class="pre">django.contrib.admin</span></code></a></li>
<li><a class="reference internal" href="#django-contrib-auth"><code class="docutils literal notranslate"><span class="pre">django.contrib.auth</span></code></a></li>
<li><a class="reference internal" href="#django-contrib-gis"><code class="docutils literal notranslate"><span class="pre">django.contrib.gis</span></code></a></li>
<li><a class="reference internal" href="#django-contrib-postgres"><code class="docutils literal notranslate"><span class="pre">django.contrib.postgres</span></code></a></li>
<li><a class="reference internal" href="#django-contrib-sitemaps"><code class="docutils literal notranslate"><span class="pre">django.contrib.sitemaps</span></code></a></li>
<li><a class="reference internal" href="#cache">Cache</a></li>
<li><a class="reference internal" href="#file-storage">File Storage</a></li>
<li><a class="reference internal" href="#forms">Forms</a></li>
<li><a class="reference internal" href="#generic-views">Generic Views</a></li>
<li><a class="reference internal" href="#management-commands">Management Commands</a></li>
<li><a class="reference internal" href="#migrations">Migrations</a></li>
<li><a class="reference internal" href="#models">Models</a></li>
<li><a class="reference internal" href="#pagination">Pagination</a></li>
<li><a class="reference internal" href="#requests-and-responses">Requests and Responses</a></li>
<li><a class="reference internal" href="#templates">Templates</a></li>
<li><a class="reference internal" href="#tests">Tests</a></li>
<li><a class="reference internal" href="#validators">Validators</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#backwards-incompatible-changes-in-2-0">Backwards incompatible changes in 2.0</a><ul>
<li><a class="reference internal" href="#removed-support-for-bytestrings-in-some-places">Removed support for bytestrings in some places</a></li>
<li><a class="reference internal" href="#database-backend-api">Database backend API</a></li>
<li><a class="reference internal" href="#dropped-support-for-oracle-11-2">Dropped support for Oracle 11.2</a></li>
<li><a class="reference internal" href="#default-mysql-isolation-level-is-read-committed">Default MySQL isolation level is read committed</a></li>
<li><a class="reference internal" href="#abstractuser-last-name-max-length-increased-to-150"><code class="docutils literal notranslate"><span class="pre">AbstractUser.last_name</span></code> <code class="docutils literal notranslate"><span class="pre">max_length</span></code> increased to 150</a></li>
<li><a class="reference internal" href="#queryset-reverse-and-last-are-prohibited-after-slicing"><code class="docutils literal notranslate"><span class="pre">QuerySet.reverse()</span></code> and <code class="docutils literal notranslate"><span class="pre">last()</span></code> are prohibited after slicing</a></li>
<li><a class="reference internal" href="#form-fields-no-longer-accept-optional-arguments-as-positional-arguments">Form fields no longer accept optional arguments as positional arguments</a></li>
<li><a class="reference internal" href="#call-command-validates-the-options-it-receives"><code class="docutils literal notranslate"><span class="pre">call_command()</span></code> validates the options it receives</a></li>
<li><a class="reference internal" href="#indexes-no-longer-accept-positional-arguments">Indexes no longer accept positional arguments</a></li>
<li><a class="reference internal" href="#foreign-key-constraints-are-now-enabled-on-sqlite">Foreign key constraints are now enabled on SQLite</a></li>
<li><a class="reference internal" href="#miscellaneous">Miscellaneous</a></li>
</ul>
</li>
<li><a class="reference internal" href="#features-deprecated-in-2-0">Features deprecated in 2.0</a><ul>
<li><a class="reference internal" href="#context-argument-of-field-from-db-value-and-expression-convert-value"><code class="docutils literal notranslate"><span class="pre">context</span></code> argument of <code class="docutils literal notranslate"><span class="pre">Field.from_db_value()</span></code> and <code class="docutils literal notranslate"><span class="pre">Expression.convert_value()</span></code></a></li>
<li><a class="reference internal" href="#id1">Miscellaneous</a></li>
</ul>
</li>
<li><a class="reference internal" href="#features-removed-in-2-0">Features removed in 2.0</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="2.0.1.html"
                        title="previous chapter">Django 2.0.1 release notes</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="1.11.29.html"
                        title="next chapter">Django 1.11.29 release notes</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/releases/2.0.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Mar 04, 2020</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    &laquo; <a href="2.0.1.html" title="Django 2.0.1 release notes">previous</a>
     |
    <a href="index.html" title="Release notes" accesskey="U">up</a>
   |
    <a href="1.11.29.html" title="Django 1.11.29 release notes">next</a> &raquo;</div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>